﻿using System.Globalization;
using Microsoft.SharePoint;
using System;

namespace SP.Exporters.Extractors
{
    public class StandardTokenValueExtractor : IStandardTokenValueExtractor
    {
        public string GetFieldValue(string standardTokenField, string format)
        {
            switch (standardTokenField)
            {
                case "ME":
                    return SPContext.Current.Web.CurrentUser.Name;
                case "NOW":
                    return String.IsNullOrEmpty(format)
                               ? DateTime.Now.ToString(CultureInfo.CurrentUICulture)
                               : DateTime.Now.ToString(format, CultureInfo.CurrentUICulture);
                default:
                    return String.Empty;
            }
        }
    }
}
